#ifndef MYWEBTAB_H
#define MYWEBTAB_H

#include <QtCore>
#include <QTableWidget>
#include <QtWebEngineWidgets>
#include <QLayout>
#include "mywebtabmgr.h"

class MyWebTabMgr;
class MyWebTab;

class MyWebView : public QWebEngineView{
    Q_OBJECT
public:
    MyWebView(MyWebTabMgr* pTabMgr, QWidget* pParent);
    QWebEngineView *createWindow(QWebEnginePage::WebWindowType type) ;
private:
    MyWebTabMgr* m_pTabMgr;
};

class MyWebTab : public QFrame
{
    Q_OBJECT
public:
    MyWebTab(MyWebTabMgr* pTabMgr, QWebEngineProfile* profile);
    void setUrl(QString strUrl);
    int getTabIndex();
    MyWebView *getWebView();
    QWebEngineProfile *getWebProfile();

public slots:
    void notify_msg(QString msg);
    // src
    void iconChanged(QIcon ico);
    void titleChanged(QString title);
    void loadProgress(int nVal);
    void urlChanged(QUrl url);
    void loadFinished(bool bHasErr);
private:
    MyWebTabMgr* m_pTabMgr;
    MyWebView* m_pWebView;
    QWebEnginePage* m_pWebPage;
    QWebEngineProfile* m_pWebProfile;
    QProgressBar* m_pProcess;
    QVBoxLayout* m_pLayout;
};

#endif // MYWEBTAB_H
